<?php
class Activity extends Action implements IAction {
	private $_logger;
	public function __construct() {
		parent::__construct ();
		Logger::configure ( ROOT_PATH . 'config/log_config.xml' );
		$this->_logger = Logger::getLogger ( __CLASS__ );
	}
	
	/**
	 * <h2>活动首页控制器</h2>
	 */
	public function indexAction() {
		global $start_time;
		$vr = new SmartyViewHelper ();
		$vr->assign ( 'title', '活动首页' );
		
		$vr->render ( 'file:activity/activity_index.htm' );
	}
	
	/**
	 * 活动的详细页
	 */
	public function detailAction() {
		$vr = new SmartyViewHelper ();
		$sm = SessionManager::getSingleton ();
		$request = new Request ();
		
		$vr->render ( 'file:activity/activity_detail.htm' );
	}
	
	/**
	 * 活动发布
	 */
	public function publishAction() {
		$request = new Request ();
		$vr = new SmartyViewHelper ();
		$ok = false;
		
		$activity = new CMAP ();
		$form = new CMAP ();
		if ($request->isPost ()) {
			/*
			 * 获取参数
			 */
			$name = new CSTRING ( $request->getPost ( 'name' ) );
			$category = new CINT ( $request->getPost ( 'category' ) );
			$province = new CINT ( $request->getPost ( 'province' ) );
			$city = new CINT ( $request->getPost ( 'city' ) );
			$district = new CINT ( $request->getPost ( 'district' ) );
			$address = new CSTRING ( $request->getPost ( 'address' ) );
			$stime = new CSTRING ( $request->getPost ( 'stime' ) );
			$etime = new CSTRING ( $request->getPost ( 'etime' ) );
			$sentime = new CSTRING ( $request->getPost ( 'sentime' ) );
			$eentime = new CSTRING ( $request->getPost ( 'eentime' ) );
			$master = new CSTRING ( $request->getPost ( 'master' ) );
			$contact_tel = new CSTRING ( $request->getPost ( 'contact_tel' ) );
			$contact_qq = new CSTRING ( $request->getPost ( 'contact_qq' ) );
			$maxmale = new CINT ( $request->getPost ( 'maxmale' ) );
			$maxfemale = new CINT ( $request->getPost ( 'maxfemale' ) );
			$costtype = new CINT ( $request->getPost ( 'costtype' ) );
			$cost = new CFLOAT ( $request->getPost ( 'cost' ) );
			$male_cost = new CFLOAT ( $request->getPost ( 'male_cost' ) );
			$female_cost = new CFLOAT ( $request->getPost ( 'female_cost' ) );
			$intro = new CSTRING ( $request->getPost ( 'intro' ) );
			
			$config = array (
					'safe' => 1 
			);
			$intro = htmLawed ( $intro, array (
					'safe' => 1 
			) );
			echo $intro;
			// $this->_redirect ( '/activity/publish' );
		}
		$t = new CMAP ();
		$vr->assign ( 'activity', $t );
		$e = new CMAP ();
		$vr->assign ( 'error', $e );
		
		$vr->render ( 'file:activity/activity_publish.htm' );
	}
	
	/**
	 * <h2>处理活动图片的上传</h2>
	 * 可处理多图片
	 * 每上传一个图片，将路径写入会话'act_imgs'
	 */
	public function imageUploadAction() {
		$this->_logger->info ( $_POST );
		echo "GOOD";
	}
	/**
	 * 删除活动
	 */
	public function deleteAction() {
	}
	
	/**
	 * 更新活动
	 */
	public function updateAction() {
	}       
	
	/**
	 * 推荐活动
	 */
	public function recommendAction() {
	}
	
	/**
	 * 置顶活动
	 */
	public function stickAction() {
	}
	
	/**
	 * 评论活动
	 */
	public function replyAction() {
	}
	
	/**
	 * 给活动打分
	 */
	public function rateAction() {
	}
	
	/**
	 * 活动反馈
	 */
	public function feedbackAction() {
	}
	
	/**
	 * 请求加入活动
	 */
	public function joinAction() {
	}
	
	/**
	 * 退出活动
	 */
	public function quitAction() {
	}
	
	/**
	 * 锁定活动
	 */
	public function lockAction() {
	}
	
	/**
	 * 购买活动
	 */
	public function payAction() {
	}
	
	/**
	 * <h2>我发起的活动</h2>
	 */
	public function myAction() {
	}
	/*
	 * (non-PHPdoc) @see IAction::addListener()
	 */
	public function addListener(ActionListener $listener) {
		// TODO Auto-generated method stub
	}
	
	/*
	 * (non-PHPdoc) @see IAction::removeListener()
	 */
	public function removeListener(ActionListener $listener) {
		// TODO Auto-generated method stub
	}
	
	/*
	 * (non-PHPdoc) @see IAction::removeAllListener()
	 */
	public function removeAllListener() {
		// TODO Auto-generated method stub
	}
}
